<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>静态属性</title>
</head>
<body>
    <script>
        // function Web(url){
        //     this.url = url;
        // }
        // // 每个对象都共用的属性叫做静态属性(静态属性即为类设置属性，而不是为生成的对象设置)
        // Web.site = "https://xiasnn/";
        // console.dir(Web);

        // let web1 = new Web('hahhahah');
        // console.log(web1.site);  //undefind
        // console.log(Web.site);   //https://xiasnn/
        


        class Request{
            // 每个对象都共用的属性叫做静态属性
            static site = "https://xiasnn/";
            constructor(url){
                this.url = url;
            }
            api(){
                console.log(Request.site + this.url);
            }
        }

        let request = new Request('fdhsgjdkfg');
        request.api();
    </script>
</body>
</html>